﻿using System;
using System.Data;
using System.Collections.Generic;
using ZX.HIS.Common;
using ZX.HIS.Model;
using ZX.HIS.DALFactory;
using ZX.HIS.IDAL;
namespace ZX.HIS.BLL
{
    /// <summary>
    /// RegistInfo
    /// </summary>
    public partial class RegistInfo
    {
        private readonly IRegistInfo dal = DataAccess.CreateRegistInfo();
        public RegistInfo()
        { }
        #region 挂号信息保存表自写方法
        /// <summary>
        /// 返回挂号信息
        /// </summary>
        /// <returns></returns>
        public int RegistInfoTopRegistId(int DepartId, int UserIdOne, int HospitalId)
        {
            return dal.RegistInfoTopRegistId(DepartId, UserIdOne, HospitalId);
        }
        /// <summary>
        /// 未就诊人数
        /// </summary>
        /// <param name="RIModel"></param>
        /// <returns></returns>
        public int RegistInfoCount(int DepartId, int UserIdOne, int HospitalId)
        {
            return dal.RegistInfoCount(DepartId, UserIdOne, HospitalId);
        }
        /// <summary>
        /// 当前诊所下的所有挂号信息
        /// </summary>
        /// <param name="HospitalId"></param>
        /// <returns></returns>
        public List<ZX.HIS.Model.RegistInfo> RegistInfoList(int HospitalId)
        {
            return dal.RegistInfoList(HospitalId);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZX.HIS.Model.RegistInfo RegistInfoGetModel(int RegistId)
        {
            return dal.RegistInfoGetModel(RegistId);
        }

        /// <summary>
        /// 挂号信息分页查询
        /// </summary>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">每页条数</param>
        /// <param name="StrWhere">查询条件</param>
        /// <param name="StrOrder">排序条件</param>
        /// <returns></returns>
        public PageClass<ZX.HIS.Model.RegistInfo> RegistInfoPageList(int PageIndex, int PageSize, ZX.HIS.Model.RegistInfo RIModel, string StrOrder)
        {
            PageClass<ZX.HIS.Model.RegistInfo> Page = new PageClass<Model.RegistInfo>();
            Page.PageIndex = PageIndex;
            Page.PageSize = PageSize;
            Page.PageNum = dal.RegistInfoCount(RIModel);
            Page.PageCount = dal.RegistInfoCount(RIModel) / PageSize;
            int PageCount = dal.RegistInfoCount(RIModel) % PageSize;
            if (PageCount > 0)
            {
                Page.PageCount = Page.PageCount + 1;
            }
            Page.PageList = dal.RegistInfoPageList(PageIndex, PageSize, RIModel, StrOrder);
            return Page;
        }
        /// <summary>
        /// 分页总条数
        /// </summary>
        /// <param name="RIModel"></param>
        /// <returns></returns>
        public int RegistInfoCount(ZX.HIS.Model.RegistInfo RIModel)
        {
            return dal.RegistInfoCount(RIModel);
        }
        /// <summary>
        /// 添加挂号
        /// </summary>
        /// <param name="RIModel"></param>
        /// <returns></returns>
        public bool RegistInfoAdd(ZX.HIS.Model.RegistInfo RIModel)
        {
            return dal.RegistInfoAdd(RIModel);
        }
        /// <summary>
        /// 修改挂号信息
        /// </summary>
        /// <param name="RIModel"></param>
        /// <returns></returns>
        public bool RegistInfoUpt(ZX.HIS.Model.RegistInfo RIModel)
        {
            return dal.RegistInfoUpt(RIModel);
        }

        /// <summary>
        /// 获得用户表数据列表
        /// </summary>
        /// <param name="HospitalId">医院id</param>
        /// <param name="DepartId">科室id</param>
        /// <returns></returns>
        public List<ZX.HIS.Model.UserInfo> GetUserList(int HospitalId, int DepartId)
        {
            return dal.GetUserList(HospitalId, DepartId);
        }
        /// <summary>
        /// 修改状态
        /// </summary>
        /// <param name="RegistId"></param>
        /// <param name="RegistState"></param>
        /// <returns></returns>
        public bool RegistInfoUpt(int RegistId, int RegistState)
        {
            return dal.RegistInfoUpt(RegistId, RegistState);
        }
        #endregion
        #region  BasicMethod

        ///// <summary>
        ///// 得到最大ID
        ///// </summary>
        //public int GetMaxId()
        //{
        //    return dal.GetMaxId();
        //}

        ///// <summary>
        ///// 是否存在该记录
        ///// </summary>
        //public bool Exists(int RegistId)
        //{
        //    return dal.Exists(RegistId);
        //}

        ///// <summary>
        ///// 增加一条数据
        ///// </summary>
        //public int  Add(ZX.HIS.Model.RegistInfo model)
        //{
        //    return dal.Add(model);
        //}

        ///// <summary>
        ///// 更新一条数据
        ///// </summary>
        //public bool Update(ZX.HIS.Model.RegistInfo model)
        //{
        //    return dal.Update(model);
        //}

        ///// <summary>
        ///// 删除一条数据
        ///// </summary>
        //public bool Delete(int RegistId)
        //{

        //    return dal.Delete(RegistId);
        //}
        ///// <summary>
        ///// 删除一条数据
        ///// </summary>
        //public bool DeleteList(string RegistIdlist )
        //{
        //    return dal.DeleteList(RegistIdlist );
        //}

        ///// <summary>
        ///// 得到一个对象实体
        ///// </summary>
        //public ZX.HIS.Model.RegistInfo GetModel(int RegistId)
        //{

        //    return dal.GetModel(RegistId);
        //}

        ///// <summary>
        ///// 得到一个对象实体，从缓存中
        ///// </summary>
        //public ZX.HIS.Model.RegistInfo GetModelByCache(int RegistId)
        //{

        //    string CacheKey = "RegistInfoModel-" + RegistId;
        //    object objModel = ZX.HIS.Common.DataCache.GetCache(CacheKey);
        //    if (objModel == null)
        //    {
        //        try
        //        {
        //            objModel = dal.GetModel(RegistId);
        //            if (objModel != null)
        //            {
        //                int ModelCache = ZX.HIS.Common.ConfigHelper.GetConfigInt("ModelCache");
        //                ZX.HIS.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
        //            }
        //        }
        //        catch{}
        //    }
        //    return (ZX.HIS.Model.RegistInfo)objModel;
        //}

        ///// <summary>
        ///// 获得数据列表
        ///// </summary>
        //public DataSet GetList(string strWhere)
        //{
        //    return dal.GetList(strWhere);
        //}
        ///// <summary>
        ///// 获得前几行数据
        ///// </summary>
        //public DataSet GetList(int Top,string strWhere,string filedOrder)
        //{
        //    return dal.GetList(Top,strWhere,filedOrder);
        //}
        ///// <summary>
        ///// 获得数据列表
        ///// </summary>
        //public List<ZX.HIS.Model.RegistInfo> GetModelList(string strWhere)
        //{
        //    DataSet ds = dal.GetList(strWhere);
        //    return DataTableToList(ds.Tables[0]);
        //}
        ///// <summary>
        ///// 获得数据列表
        ///// </summary>
        //public List<ZX.HIS.Model.RegistInfo> DataTableToList(DataTable dt)
        //{
        //    List<ZX.HIS.Model.RegistInfo> modelList = new List<ZX.HIS.Model.RegistInfo>();
        //    int rowsCount = dt.Rows.Count;
        //    if (rowsCount > 0)
        //    {
        //        ZX.HIS.Model.RegistInfo model;
        //        for (int n = 0; n < rowsCount; n++)
        //        {
        //            model = dal.DataRowToModel(dt.Rows[n]);
        //            if (model != null)
        //            {
        //                modelList.Add(model);
        //            }
        //        }
        //    }
        //    return modelList;
        //}

        ///// <summary>
        ///// 获得数据列表
        ///// </summary>
        //public DataSet GetAllList()
        //{
        //    return GetList("");
        //}

        ///// <summary>
        ///// 分页获取数据列表
        ///// </summary>
        //public int GetRecordCount(string strWhere)
        //{
        //    return dal.GetRecordCount(strWhere);
        //}
        ///// <summary>
        ///// 分页获取数据列表
        ///// </summary>
        //public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        //{
        //    return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
        //}
        ///// <summary>
        ///// 分页获取数据列表
        ///// </summary>
        ////public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        ////{
        //    //return dal.GetList(PageSize,PageIndex,strWhere);
        ////}

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

